<html>
<head><meta charset="utf-8"><title>raw_ref macros · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html">raw_ref macros</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="221212080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221212080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221212080">(Dec 30 2020 at 13:25)</a>:</h4>
<p>I wonder if the libs team has any opinion on the name of the raw_ref macros, currently <code>std::ptr::raw_mut!</code> and <code>std::ptr_raw_const!</code>? See <a href="https://github.com/rust-lang/rust/issues/73394#issuecomment-751342185">here</a> for why I am not a big fan of the current names.</p>



<a name="221212353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221212353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221212353">(Dec 30 2020 at 13:30)</a>:</h4>
<p>not libs team but <code>const_raw!</code> does seem better than <code>raw_const!</code>. neither are great though. i think people will be confused by the <code>const</code> in the name (i know i was at first, despite writing lots of unsafe code).</p>



<a name="221212458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221212458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221212458">(Dec 30 2020 at 13:32)</a>:</h4>
<p>also, i assume you mean something other than <code>const_mut!</code> in that github issue you've linked? perhaps <code>mut_raw!</code>/<code>raw_mut!</code>? not sure, but <code>const_mut!</code> just seems wrong</p>



<a name="221284720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221284720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221284720">(Dec 31 2020 at 11:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/219381-t-libs/topic/raw_ref.20macros/near/221212458">said</a>:</p>
<blockquote>
<p>also, i assume you mean something other than <code>const_mut!</code> in that github issue you've linked? perhaps <code>mut_raw!</code>/<code>raw_mut!</code>? not sure, but <code>const_mut!</code> just seems wrong</p>
</blockquote>
<p>d'oh, what was I thinking...</p>



<a name="221284721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221284721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221284721">(Dec 31 2020 at 11:35)</a>:</h4>
<p>yeah I mean <code>std::ptr::mut_raw!</code>, mirroring the proposed <code>std::ptr::const_raw!</code></p>



<a name="221285160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221285160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221285160">(Dec 31 2020 at 11:46)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/219381-t-libs/topic/raw_ref.20macros/near/221212353">said</a>:</p>
<blockquote>
<p>not libs team but <code>const_raw!</code> does seem better than <code>raw_const!</code>. neither are great though. i think people will be confused by the <code>const</code> in the name (i know i was at first, despite writing lots of unsafe code).</p>
</blockquote>
<p>Do you see any way to avoid the <code>const</code> though? The type is spelled <code>*const T</code>, after all...</p>



<a name="221285181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221285181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221285181">(Dec 31 2020 at 11:47)</a>:</h4>
<p>I guess the other alternative would be <code>std::ptr::raw!</code> and <code>std::ptr::raw_mut!</code>. Not sure I like that, though.</p>



<a name="221297713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221297713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221297713">(Dec 31 2020 at 15:49)</a>:</h4>
<p>And these are kept together when alphabetically ordered</p>



<a name="221299714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221299714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221299714">(Dec 31 2020 at 16:18)</a>:</h4>
<p>/me wonders why raw pointers ended up with "const" when references didn't.</p>



<a name="221300787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221300787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221300787">(Dec 31 2020 at 16:34)</a>:</h4>
<p>There was an RFC! <a href="https://github.com/rust-lang/rfcs/blob/master/text/0068-const-unsafe-pointers.md">https://github.com/rust-lang/rfcs/blob/master/text/0068-const-unsafe-pointers.md</a></p>



<a name="221301575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221301575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221301575">(Dec 31 2020 at 16:46)</a>:</h4>
<p>Interesting!</p>



<a name="221407590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221407590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221407590">(Jan 02 2021 at 17:03)</a>:</h4>
<p>I guess another option would be just <code>ptr::const!</code> and <code>ptr::mut!</code> -- assuming "ptr/pointer" implies "raw" (which I often see people do)</p>



<a name="221407594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221407594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221407594">(Jan 02 2021 at 17:03)</a>:</h4>
<p>or, if we want to ditch the idea of having the macros inside a module, <code>const_ptr!</code> and <code>mut_ptr!</code></p>



<a name="221409656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221409656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221409656">(Jan 02 2021 at 17:54)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/219381-t-libs/topic/raw_ref.20macros/near/221407590">said</a>:</p>
<blockquote>
<p>I guess another option would be just <code>ptr::const!</code> and <code>ptr::mut!</code> -- assuming "ptr/pointer" implies "raw" (which I often see people do)</p>
</blockquote>
<p>I would guess that it can't be those, though, as they're keywords.</p>



<a name="221410692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221410692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221410692">(Jan 02 2021 at 18:19)</a>:</h4>
<p>ah, good point</p>



<a name="221410967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221410967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221410967">(Jan 02 2021 at 18:25)</a>:</h4>
<p>As for <code>const_ptr!</code>, I think there's technically a naming guideline to not repeat module names.</p>
<p>I don't know how fond of that people are these days, though.  I remember some musings that maybe it would have been better to have <code>fmt::FormatResult</code> instead of <code>fmt::Result</code>, for example.  And I think it's likely that there will soon be <code>array::ArrayVec</code>.</p>



<a name="221411232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221411232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221411232">(Jan 02 2021 at 18:30)</a>:</h4>
<blockquote>
<p>As for const_ptr!, I think there's technically a naming guideline to not repeat module names.</p>
</blockquote>
<p>it wouldn't be repeated if the macro lives in the crate root :D (like all current macros do)</p>



<a name="221458293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/221458293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#221458293">(Jan 03 2021 at 16:21)</a>:</h4>
<p>hm, what about <code>ptr::const_addr_of!</code> and <code>ptr::mut_addr_of!</code>?</p>



<a name="222242499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/raw_ref%20macros/near/222242499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/raw_ref.20macros.html#222242499">(Jan 10 2021 at 21:15)</a>:</h4>
<p>Stabilization PR with those last names I proposed is up: <a href="https://github.com/rust-lang/rust/pull/80886">https://github.com/rust-lang/rust/pull/80886</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>